<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" placeholder="请输入一百以内的整数" v-model="guess">
  <input type="button" value="猜一猜" @click="f">
  <h3>结果：{{result}}</h3>
</div>
</body>
<script src="js/vue.min.js"></script>
<script>
  let num = parseInt(Math.random() * 100 + 1);
  let times = 0;
  let v = new Vue({
    el: "body>div",
    data: {guess: "",result: ""},
    methods: {
      f() {
        if (v.guess == num) {
          v.result = "恭喜你，"+times+"次猜对了！"
          return;
        }
        if (v.guess < num) {
          times++;
          v.result = "猜小了！";
        }
        if (v.guess > num) {
          times++;
          v.result = "猜大了！"
        }
      }
    }
  });
</script>
</html>